//
//  NotificationViewController.m
//  NotificationContentExtension
//
//  Created by Jim1024 on 2016/12/30.
//  Copyright © 2016年 Jim1024. All rights reserved.
//

#import "NotificationViewController.h"
#import <UserNotifications/UserNotifications.h>
#import <UserNotificationsUI/UserNotificationsUI.h>

@interface NotificationViewController () <UNNotificationContentExtension>

@property IBOutlet UILabel *label;

@end

@implementation NotificationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any required interface initialization here.
}

- (void)didReceiveNotification:(UNNotification *)notification {
    self.label.text = notification.request.content.body;
    
    NSDictionary *dict =  notification.request.content.userInfo;
    // 这里可以把打印的所有东西拿出来
    NSLog(@"%@",dict);
}

- (UNNotificationContentExtensionMediaPlayPauseButtonType)mediaPlayPauseButtonType
{
    return UNNotificationContentExtensionMediaPlayPauseButtonTypeDefault;
}

- (CGRect)mediaPlayPauseButtonFrame
{
    return CGRectMake(100, 30, 50, 50);
}

- (UIColor *)mediaPlayPauseButtonTintColor{
    return [UIColor blueColor];
}

- (void)mediaPlay{
    NSLog(@"mediaPlay,开始播放");
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(4.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self.extensionContext mediaPlayingPaused];
    });
    
}
- (void)mediaPause{
    NSLog(@"mediaPause，暂停播放");
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(10.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self.extensionContext mediaPlayingStarted];
    });
    
}

- (void)mediaPlayingStarted{
    NSLog(@"主动调用开始的方法");
}
- (void)mediaPlayingPaused
{
    NSLog(@"主动调用暂停的方法");
    
}

@end
